<template>

    <el-card class="box-card" >
    <div v-for="item in imgs" style="display: flex">
        <img :src="item.avatar" style="width: 30%"/>
    </div>
        <el-upload
                action="https://jsonplaceholder.typicode.com/posts/"
                list-type="picture-card"
                :on-preview="handlePictureCardPreview"
                :on-remove="handleRemove">
            <i class="el-icon-plus"></i>
        </el-upload>
        <el-dialog :visible.sync="dialogVisible">
            <img width="100%" :src="dialogImageUrl" alt="">
        </el-dialog>
</el-card>

</template>

<script>
    import request from '@/utils/request'
    export default {
        data() {
            return {
                dialogImageUrl: '',
                dialogVisible: false,
                form:{},
                imgs:[]
            };
        },
        created(){
            this.form = sessionStorage.getItem("user") ? JSON.parse(sessionStorage.getItem("user")) : {};
            this.load()
        },
        methods: {
            load(){

              request.get("/user/all").then(res=>{

                  this.imgs=res.data
                  console.log(this.imgs)
              })
            },

            handleRemove(file, fileList) {
                console.log(file, fileList);
            },
            handlePictureCardPreview(file) {
                this.dialogImageUrl = file.url;
                this.dialogVisible = true;
            }
        }
    }
</script>

<style>
    .text {
        font-size: 14px;
    }

    .item {
        padding: 18px 0;
    }

    .box-card {
        width: 480px;
    }
</style>
